<?php

class edit_division
{
	var $id;
	var $title;
	var $signuplimit;
	var $ranking;
	var $champid;
	var $order;
	
	var $add_record;
	var $valid;

	function edit_division($add_record, $champ_id, $record='')
	{
		if($add_record)
		{
			$this->add_record = true;
			$this->id = '';
			$this->title = '';
			$this->signuplimit = '';
			$this->order = '';
			$this->ranking = 1;
			$this->champid = $champ_id;
			$this->eventslimit = '';
			$this->valid = true;
		}
		else if(!$add_record)
		{
			$this->add_record = false;
			$this->id = $record['d_id'];
			$this->title = $record['d_title'];
			$this->signuplimit = $record['d_signuplimit'];
			$this->order = $record['d_order'];
			$this->eventslimit = $record['d_drivermaxevents'];
			$this->ranking = $record['d_ranking'];
			$this->champid = $champ_id;
			$this->valid = true;
		}
		else
		{
			$this->valid = false;
		}
	}

	function render()
	{		
		global $skin_dir, $lang;
		
		$submitText = $this->add_record ? $lang['AddButton'] : $lang['EditButton'];
		$submitValue = $this->add_record ? 'addRecord' : 'editRecord';
		$remS = $this->add_record ? '<!--' : '';
		$remE = $this->add_record ? '-->' : '';
		
		$title = $this->title;
		$champid = $this->champid;
		$id = $this->id;
		$signuplimit = $this->signuplimit;
		$ranking = $this->ranking;
		$order = $this->order;
		$eventslimit = $this->eventslimit;
		
		include $skin_dir . 'admin/editdivision.tpl';
	}
}
?>